import service from "../index.js";
import qs from "qs";

const serviceApi = {
    //添加房间
    insert(serviceData){
        return service.post('/admin/service',serviceData);
    },
    //根据id删除
    delete(id){
        return service.delete(`/admin/service/${id}`)
    },
    //根据ids删除
    deleteByIds(ids){
        return service.delete(`/admin/service/byIds`,  {
            params: { ids }, // 改为对象格式
            paramsSerializer: params =>
                qs.stringify(params, { arrayFormat: 'repeat' })
        })
    },
    //修改
    update(serviceData){
        return service.put('/admin/service',serviceData);
    },
    //根据ids删除
    updateByRooms(services){
        return service.post(`/admin/service/byRooms`,services)
    },
    //查询所有
    selectByPage(pageNum, pageSize,prop,order, serviceData){
        serviceData.pageNum = pageNum;
        serviceData.pageSize = pageSize;
        serviceData.prop = prop;
        serviceData.order = order;
        //请求参数
        return service.get('/admin/service', {params: serviceData});
    },
    //根据id查询
    selectById(id){
        return service.get(`/admin/service/${id}`)
    },
}
export default serviceApi;